package Fisica;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import Fisica.Conexion;
//import Modelo.Articulo;
import Modelo.Fac_Articulos;

public class ProcCoope {
	
	
	public static Modelo.Fac_Articulos getArticulo (String cod_barra){
		String sql = "select a.* "
				+ "from fac_articulos_barras as b, fac_articulos as a "
				+ "where b.art_barras = '"+cod_barra+"' and b.art_codigo = a.art_codigo;";
		try {
			PreparedStatement st = Conexion.getConexion().prepareStatement(sql);	
			ResultSet rs = st.executeQuery();			
			
			if (rs.next()){
				Modelo.Fac_Articulos a = new Modelo.Fac_Articulos(); 
				a.setCodInterno(rs.getString("art_codigo")); 	
				a.setCodBarra(rs.getString("art_barras"));
				a.setDescripcion(rs.getString("art_descri"));	
				
				return a;
			}			
		} catch (SQLException e) {
			System.out.print("ERROR EN LA RECUPERACION DE DATOS DE LA BASE");
			e.printStackTrace();
		} 				
		return new Fac_Articulos();
	}
	

	

	public static void main(String[] args) {
		ProcCoope p = new ProcCoope();
//		p.getArticulo();


	}

}
